<?php $form = $this->beginWidget('CActiveForm', array('id' => 'video-form', 'enableAjaxValidation' => true)); ?>
<table cellspacing="1" cellpadding="4" width="100%">
    <tr align="center" valign="top">
        <td width="*" align="center" valign="top">
            <div class="Block">
                <div class="BlockBar"><?php echo CHtml::activeLabel($model, 'video_add_title'); ?></div>
                <!-- tab bar -->
                <div id="tabbar-div">
                    <ul>
                        <li class="tab-front" id="general">基本信息</li>
                        <li class="tab-back" id="details">视频简介</li>
                    </ul>
                </div>
                <!-- tab end -->
                <span id="test"><?php echo $this->message; ?></span>
                <?php echo $form->errorSummary($model); ?>
                <table width="100%" cellpadding="4" cellspacing="1" class="tab">
                    <tbody class="tabbar general">
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_name'); ?>:</td>
                            <td><?php echo $form->textField($model, 'video_name', array('size' => 40, 'maxlength' => 40)); ?>
                                <?php echo $form->error($model, 'video_name'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_directors'); ?>:</td>
                            <td><?php echo $form->textField($model, 'video_directors', array('size' => 40, 'maxlength' => 40)); ?>
                                <?php echo $form->error($model, 'video_directors'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_actors'); ?>:</td>
                            <td><?php echo $form->textField($model, 'video_actors', array('size' => 40, 'maxlength' => 40)); ?><?php echo $form->error($model, 'video_actors'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_alias'); ?>:</td>
                            <td><?php echo $form->textField($model, 'video_alias', array('size' => 40, 'maxlength' => 40)); ?><?php echo $form->error($model, 'video_alias'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_release'); ?>:</td>
                            <td><?php echo $form->textField($model, 'video_release', array('size' => 40, 'maxlength' => 40)); ?>
                                <?php echo $form->error($model, 'video_release'); ?></td>
                        </tr>
                                                <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_quality'); ?>:</td>
                            <td><?php echo $form->radioButtonList($model, 'video_quality', $model->getQualityData(), array('class' => 'checkbox', 'separator' => '')); ?>
                                <?php echo $form->error($model, 'video_quality'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_dialog'); ?>:</td>
                            <td><?php echo $form->checkBoxList($model, 'video_dialog', $model->getDialogData(), array('class' => 'checkbox', 'separator' => '')); ?>
                                <?php echo $form->error($model, 'video_dialog'); ?></td>
                        </tr>

                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_region'); ?>:</td>
                            <td><?php echo $form->checkBoxList($model, 'video_region', $model->getRegionData(), array('class' => 'checkbox', 'separator' => '')); ?>
                                <?php echo $form->error($model, 'video_region'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_play'); ?>:</td>
                            <td><?php echo $form->checkBoxList($model, 'video_play', $model->getPlayArray(), array('class' => 'checkbox', 'separator' => '')); ?><?php echo $form->error($model, 'video_play'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_play_level'); ?>:</td>
                            <td><?php echo $form->dropDownList($model, 'video_play_level', $model->getPlayUserGroup()); ?><?php echo $form->error($model, 'video_play_level'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_play_money'); ?>:</td>
                            <td><?php echo $form->textField($model, 'video_play_money'); ?><?php echo $form->error($model, 'video_play_money'); ?><?php echo $form->error($model, 'video_play_money'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_player_alias'); ?>:</td>
                            <td><?php echo $form->checkBoxList($model, 'video_player_alias', $model->getPlayer(), array('separator' => '', 'class' => 'radio')); ?><?php echo $form->error($model, 'video_player_alias'); ?></td>
                        </tr>
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_input_type'); ?>:</td>
                            <td><?php echo $form->dropDownList($model, 'video_input_type', $model->getInputMode(), array('separator' => '', 'class' => 'radio', 'onclick' => 'show(this)')); ?></td>
                        </tr>
                        <tr class="row hide" id="input_type_1">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'video_textarea'); ?>:</td>
                            <td><?php echo $form->textArea($model, 'video_textarea', array('cols' => '50')); ?><?php echo $form->error($model, 'video_textarea'); ?></td>
                        </tr>
                    </tbody>
                    <tbody id="input_type_0" class="tabbar general">
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo Yii::t('default', '批量生成视频路径');?></td>
                            <td><div class="left space-level"><?php echo $form->textField($model, 'playPrefix', array('size' => 40)); ?> <?php echo $form->textField($model, 'playStart', array('size' => 3)); ?>至<?php echo $form->textField($model, 'playEnd', array('size' => 3)); ?>视频格式<?php echo $form->textField($model, 'playExtension', array('size' => 5, 'value' => '.rmvb')); ?></div>
                                <?php echo CHtml::submitButton(Yii::t('default', '生成点播地址'), array('class' => 'btns', 'id' => "makePlay", 'name' => 'make')); ?></td>
                        </tr>
                        <?php if ($this->end > 0): ?>
                            <tr class="row">
                                <td></td>
                                <td>
                                    <div id="urlItem">
                                        <div><span class="url"><?php echo $form->labelEx($model, 'video_url'); ?></span><span class="title"><?php echo $form->labelEx($model, 'video_title'); ?></span><span class="type"><?php echo $form->labelEx($model, 'video_type'); ?></span><span></span></div>
                                        <?php foreach($model->files as $file): ?>
                                            <div><span><input type="text" name="Video[video_url][]" class="url" value="<?php echo $file['file_path'] ;?>" /></span><span><input type="text" name="Video[video_title][]" class="title" value="<?php echo $file['file_name'] ;?>"  /></span><span class="type"><?php echo $model->getUrlTypeOption($model->files['file_play_mode']); ?></span><span><a href="javascript:void(0)" class="remove"><?php echo Yii::t('default', '删除'); ?></a></span></div>
                                        <?php endforeach; ?>
                                        <?php for ($i = $this->start; $i <= $this->end; $i++): ?>
                                            <div><span><input type="text" name="Video[video_url][]" class="url" value="<?php echo isset($model->video_url[$i]) ? $model->video_url[$i] : $model->playPrefix . $i . $model->playExtension; ?>" /></span><span><input type="text" name="Video[video_title][]" class="title" value="<?php echo isset($model->video_title[$mi]) ? $model->video_title[$i] : $i; ?>"  /></span><span class="type"><?php echo $model->getUrlTypeOption($model->video_type[$i]); ?></span><span><a href="javascript:void(0)" class="remove"><?php echo Yii::t('default', '删除'); ?></a></span></div>
                                        <?php endfor; ?>
                                    </div>

                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                    <tbody class="hide tabbar details">
                        <?php $this->renderPartial('upload', array('model' => $model, 'form' => $form)); ?>
                    </tbody>
                    <tr class="rows">
                        <td class="rows"></td>
                        <td class="rows"><?php echo CHtml::submitButton(Yii::t('app', '提 交'), array('class' => 'btn')); ?></td>
                    </tr>
                </table>
            </div></td>
        <td width="5"></td>
        <td width="250" align="center" valign="top"><div class="Block-Menu-Define">
                <div class="BlockBar"><?php echo Yii::t('default', '选择所属分类');?></div>
                <div class="BlockLinks">
                    <ul>
                        <?php echo $model->getCategoryList($model->video_category); ?>
                    </ul>
                </div>
                <div class="BlockBar"><?php echo Yii::t('default', '选择视频所在服务器');?></div>
                <div class="BlockLinks">
                    <ul>
                        <?php echo $model->getServerList($model->video_play_server); ?>
                    </ul>
                </div>
            </div></td>
    </tr>
</table>
<?php $this->endWidget(); ?>
<script>
    $("#tabbar-div").find("li").click(function (){
        $("#tabbar-div").find("li").removeClass("tab-front");
        $("#tabbar-div").find("li").addClass("tab-back");
        $(this).addClass('tab-front');
        $(this).removeClass('tab-back');
        $('.tabbar').hide();
        var name = $(this).attr('id');
        $('.'+name).removeClass('hide');
        $('.'+name).show();
    });
    $(".remove").click(function (){
        $(this).parent().parent().remove();
    });
    function show(obj){
        if($(obj).val() == 0){
            $('#input_type_1').hide();
            $('#input_type_0').show();
        }else{
            $('#input_type_1').show();
            $('#input_type_0').hide();
        }
    }
</script>
